import ServiceNet from '../../servicenet.js';
import BaseList from '../base/BaseList.js';
import UserListItem from './UserListItem.js';
import Friend from './Friend.js';
import Black from '../blacklist/Black.js';

function UserList () {
    BaseList.call(this);
 }
let prototype = Object.create(BaseList.prototype);
prototype.constructor = UserList;
UserList.prototype  = prototype;

UserList.prototype.search = function(value){
    ServiceNet.queryUserLike(value,userIds=>{
        if(userIds.length >0){
            this.setItems( userIds.filter(userId=>!Black.isBlack(userId)).filter(userId=>!Friend.isFriend(userId)).map(userId=>new UserListItem().updateDataByUserID(userId)));
        }else{
            this.clearItems();
        }
    });
}

export default UserList;
